package com.xbongbong.paas.enums;


import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * 任务操作类型枚举
 * @author wufeng
 * @date 2018/8/22 16:37
 */
public enum TaskTypeEnum {

    /**
     * 未处理
     */
    UNTREATED(0, "untreated", "enum.taskType.memo.untreated", 0, "enum.taskType.statusMemo.untreated", "#FF8E3D"),
    /**
     * 提交
     */
    COMMIT(1, "commit", "enum.taskType.memo.commit", 1, "enum.taskType.statusMemo.commit", "#5BA307"),
    /**
     * 提交并打印
     */
    COMMIT_PRINT(2, "commitPrint", "enum.taskType.memo.commit_print", 2, "enum.taskType.statusMemo.commit_print", "#5BA307"),
    /**
     *暂存
     */
    STORAGE(3, "storage", "enum.taskType.memo.storage", 3, "enum.taskType.statusMemo.storage", ""),
    /**
     * 转交
     */
    TRANSFER(4, "transfer", "enum.taskType.memo.transfer", 4, "enum.taskType.statusMemo.transfer", "#FF8E3D"),
    /**
     * 回退
     */
    BACK(5, "back", "enum.taskType.memo.back", 5, "enum.taskType.statusMemo.back", "#FF8E3D"),
    /**
     * 激活
     */
    ACTIVATION(6, "activation", "enum.taskType.memo.activation", 6, "enum.taskType.statusMemo.activation", ""),
    /**
     * 结束流程
     */
    END(7, "end", "enum.taskType.memo.end", 7, "enum.taskType.statusMemo.end", "#E05353"),

    CC(8, "copy", "enum.taskType.memo.cc", 8, "enum.taskType.statusMemo.cc", ""),
    /**
     * 撤回
     */
    REVOKE(9, "revoke", "enum.taskType.memo.revoke", 9, "enum.taskType.statusMemo.revoke", ""),

    AGAIN_COMMIT(10, "againCommit", "enum.taskType.memo.again_commit", 10, "enum.taskType.statusMemo.again_commit", ""),

    OTHER_COMMIT(11, "otherCommit", "enum.taskType.memo.other_commit", 11, "enum.taskType.statusMemo.other_commit", "#5BA307"),

    WAIT_CC(12, "waitCopy", "enum.taskType.memo.wait_cc", 12, "enum.taskType.statusMemo.wait_cc", ""),

    PROCESS_COMMENT(13, "processComment", "enum.taskType.memo.process_comment", 13, "enum.taskType.statusMemo.process_comment", ""),

    SYSTEM_COMMIT(14, "systemCommit", "enum.taskType.memo.system_commit", 14, "enum.taskType.statusMemo.system_commit", ""),

    ESIGN(15, "esign", "enum.taskType.memo.esign", 15, "enum.taskType.statusMemo.esign", ""),
    /**
     * 系统自动通过(审批人去重)
     */
    SYSTEM_PASS(16, "systemPass", "enum.taskType.memo.system_pass", 16, "enum.taskType.statusMemo.system_pass", ""),

    /**
     * 移动端打印需要这么个,其他地方务用,其他地方也没办法加
     */
    PRINT(17, "print", "enum.taskType.memo.print", 17, "enum.taskType.statusMemo.print", ""),

    /**
     * 加签
     */
    ADD_SIGNATURE(18, "addSignature", "enum.taskType.memo.addSignature", 17, "enum.taskType.statusMemo.addSignature", ""),
    /**
     * 查看全流程
     */
    VIEW_WHOLE_PROCESS(19, "viewWholeProcess", "enum.taskType.memo.view_whole_process", 18, "enum.taskType.statusMemo.viewWholeProcess", ""),

    CONTRACT_COMPARE(20, "contractCompare", "enum.taskType.memo.contractCompare", 20, "enum.taskType.statusMemo.contractCompare", ""),
    ;

    private Integer type;

    private String alias;

    private String memo;

    /**
     * status和type对应,表示操作之后对应的状态 wufeng说的
     */
    private Integer status;

    /**
     * 前端显示文案
     */
    private String statusMemo;

    private String color;

    TaskTypeEnum(Integer type, String alias, String memo, Integer status, String statusMemo, String color){
        this.type = type;
        this.alias = alias;
        this.memo = memo;
        this.status = status;
        this.statusMemo = statusMemo;
        this.color = color;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getStatusMemo() {
        return I18nMessageUtil.getMessage(statusMemo);
    }

    public void setStatusMemo(String statusMemo) {
        this.statusMemo = statusMemo;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public static TaskTypeEnum getTaskTypeEnum(Integer taskType) {
        for (TaskTypeEnum t: values()) {
            if(taskType.equals(t.getType())){
                return t;
            }
        }
        return null;
    }

    public static String getMemo(Integer taskType) {
        for (TaskTypeEnum t: values()) {
            if(taskType.equals(t.getType())){
                return t.getMemo();
            }
        }
        return null;
    }

    public static String getStatusMemo(Integer taskType) {
        for (TaskTypeEnum t: values()) {
            if(taskType.equals(t.getType())){
                return t.getStatusMemo();
            }
        }
        return null;
    }
}
